<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".parent").children().hide();
	$(".parent").addClass("pointer").toggle(
		function(){$(this).children().show();
		},function(){$(this).children().hide();}
	);
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>发货日期</th>
	<td>
		<input type="text" name="begin_shipped_time" class="datepicker" value="<?=isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : ''?>" /> to
		<input type="text" name="end_shipped_time" class="datepicker" value="<?=isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : ''?>" />
	</td>
</tr>
<tr>
	<th>网站</th>
	<td><select name="shop_id">
		<option value="">请选择..</option>
		<?foreach ($shop as $s):?>
		<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id'] == $s['id']) echo "selected='selected'";?>><?=$s['name']?></option>
		<?endforeach;?>
	</select></td>
</tr>
<tr>
	<td><input type="hidden" name="is_search" value="1" /></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<?if (! empty($_GET['is_search'])):?>
<table width="50%" class="list_table" >
	<tr>
		<th>错漏发原因</th>
		<?foreach (Q::ini('custom_flag/sales_order_mark_order_flag') as $somof):?>
		<td><?=$somof['name'];?></td>
		<?endforeach;?> 
	</tr>
	<tr>
		<th>订单数量</th>
		<?foreach (Q::ini('custom_flag/sales_order_mark_order_flag') as $somof):?>
		<?$is_flag = false;?>
		<?foreach ($report as $r):?>
		<?if ($somof['value'] == $r['mark_order_flag']):?>
		<?if($_GET['shop_id']) : ?>
		<td><a href="<?=url('Sales::Order/List', array(' is_search' => '1', 'begin_shipped_time' => (isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : ''), 'end_shipped_time' => (isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : ''), 'shop_id' => isset($_GET['shop_id']) ? array($_GET['shop_id']) : '', 'mark_order_flag' => array($r['mark_order_flag'])))?>"><?=$r['quantity']?></a></td>
		<?else:?>
		<td><a href="<?=url('Sales::Order/List', array(' is_search' => '1', 'begin_shipped_time' => (isset($_GET['begin_shipped_time']) ? $_GET['begin_shipped_time'] : ''), 'end_shipped_time' => (isset($_GET['end_shipped_time']) ? $_GET['end_shipped_time'] : ''),  'mark_order_flag' => array($r['mark_order_flag'])))?>"><?=$r['quantity']?></a></td>
		<?endif;?>
		<?$is_flag = true?>
		<?endif;?>
		<?endforeach;?>
		<?if (!$is_flag):?>
		<td>0</td>
		<?endif;?>
		<?endforeach;?>
</tr>
</table>
<?endif;?>
<?php $this->_endblock();?>